\(\int \cot ^2(c+d x) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx\) [21]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 34, antiderivative size = 116 \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx=-4 a^3 (A-i B) x+\frac {a^3 (i A+3 B) \log (\cos (c+d x))}{d}+\frac {a^3 (3 i A+B) \log (\sin (c+d x))}{d}-\frac {a A \cot (c+d x) (a+i a \tan (c+d x))^2}{d}+\frac {(i A-B) \left (a^3+i a^3 \tan (c+d x)\right )}{d} \]

[Out]

-4*a^3*(A-I*B)*x+a^3*(I*A+3*B)*ln(cos(d*x+c))/d+a^3*(3*I*A+B)*ln(sin(d*x+c))/d-a*A*cot(d*x+c)*(a+I*a*tan(d*x+c
))^2/d+(I*A-B)*(a^3+I*a^3*tan(d*x+c))/d

Rubi [A] (verified)

Time = 0.33 (sec) , antiderivative size = 116, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.147, Rules used = {3674, 3675, 3670, 3556, 3612} \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx=\frac {(-B+i A) \left (a^3+i a^3 \tan (c+d x)\right )}{d}+\frac {a^3 (B+3 i A) \log (\sin (c+d x))}{d}+\frac {a^3 (3 B+i A) \log (\cos (c+d x))}{d}-4 a^3 x (A-i B)-\frac {a A \cot (c+d x) (a+i a \tan (c+d x))^2}{d} \]

[In]

Int[Cot[c + d*x]^2*(a + I*a*Tan[c + d*x])^3*(A + B*Tan[c + d*x]),x]

[Out]

-4*a^3*(A - I*B)*x + (a^3*(I*A + 3*B)*Log[Cos[c + d*x]])/d + (a^3*((3*I)*A + B)*Log[Sin[c + d*x]])/d - (a*A*Co
t[c + d*x]*(a + I*a*Tan[c + d*x])^2)/d + ((I*A - B)*(a^3 + I*a^3*Tan[c + d*x]))/d

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3612

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*c +
b*d)*(x/(a^2 + b^2)), x] + Dist[(b*c - a*d)/(a^2 + b^2), Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x]
 /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[a*c + b*d, 0]

Rule 3670

Int[(((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]))/((a_.) + (b_.)*tan[(e_.)
 + (f_.)*(x_)]), x_Symbol] :> Dist[B*(d/b), Int[Tan[e + f*x], x], x] + Dist[1/b, Int[Simp[A*b*c + (A*b*d + B*(
b*c - a*d))*Tan[e + f*x], x]/(a + b*Tan[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f, A, B}, x] && NeQ[b*c - a
*d, 0]

Rule 3674

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[(-a^2)*(B*c - A*d)*(a + b*Tan[e + f*x])^(m - 1)*((c + d*Tan[e + f*x]
)^(n + 1)/(d*f*(b*c + a*d)*(n + 1))), x] - Dist[a/(d*(b*c + a*d)*(n + 1)), Int[(a + b*Tan[e + f*x])^(m - 1)*(c
 + d*Tan[e + f*x])^(n + 1)*Simp[A*b*d*(m - n - 2) - B*(b*c*(m - 1) + a*d*(n + 1)) + (a*A*d*(m + n) - B*(a*c*(m
 - 1) + b*d*(n + 1)))*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B}, x] && NeQ[b*c - a*d, 0] && E
qQ[a^2 + b^2, 0] && GtQ[m, 1] && LtQ[n, -1]

Rule 3675

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*B*(a + b*Tan[e + f*x])^(m - 1)*((c + d*Tan[e + f*x])^(n + 1)/(d*f*
(m + n))), x] + Dist[1/(d*(m + n)), Int[(a + b*Tan[e + f*x])^(m - 1)*(c + d*Tan[e + f*x])^n*Simp[a*A*d*(m + n)
 + B*(a*c*(m - 1) - b*d*(n + 1)) - (B*(b*c - a*d)*(m - 1) - d*(A*b + a*B)*(m + n))*Tan[e + f*x], x], x], x] /;
 FreeQ[{a, b, c, d, e, f, A, B, n}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] && GtQ[m, 1] &&  !LtQ[n, -1]

Rubi steps \begin{align*} \text {integral}& = -\frac {a A \cot (c+d x) (a+i a \tan (c+d x))^2}{d}+\int \cot (c+d x) (a+i a \tan (c+d x))^2 (a (3 i A+B)+a (A+i B) \tan (c+d x)) \, dx \\ & = -\frac {a A \cot (c+d x) (a+i a \tan (c+d x))^2}{d}+\frac {(i A-B) \left (a^3+i a^3 \tan (c+d x)\right )}{d}+\int \cot (c+d x) (a+i a \tan (c+d x)) \left (a^2 (3 i A+B)-a^2 (A-3 i B) \tan (c+d x)\right ) \, dx \\ & = -\frac {a A \cot (c+d x) (a+i a \tan (c+d x))^2}{d}+\frac {(i A-B) \left (a^3+i a^3 \tan (c+d x)\right )}{d}-\left (a^3 (i A+3 B)\right ) \int \tan (c+d x) \, dx+\int \cot (c+d x) \left (a^3 (3 i A+B)-4 a^3 (A-i B) \tan (c+d x)\right ) \, dx \\ & = -4 a^3 (A-i B) x+\frac {a^3 (i A+3 B) \log (\cos (c+d x))}{d}-\frac {a A \cot (c+d x) (a+i a \tan (c+d x))^2}{d}+\frac {(i A-B) \left (a^3+i a^3 \tan (c+d x)\right )}{d}+\left (a^3 (3 i A+B)\right ) \int \cot (c+d x) \, dx \\ & = -4 a^3 (A-i B) x+\frac {a^3 (i A+3 B) \log (\cos (c+d x))}{d}+\frac {a^3 (3 i A+B) \log (\sin (c+d x))}{d}-\frac {a A \cot (c+d x) (a+i a \tan (c+d x))^2}{d}+\frac {(i A-B) \left (a^3+i a^3 \tan (c+d x)\right )}{d} \\ \end{align*}

Mathematica [A] (verified)

Time = 1.02 (sec) , antiderivative size = 94, normalized size of antiderivative = 0.81 \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx=a^3 \left (-\frac {A \cot (c+d x)}{d}+\frac {3 i A \log (\tan (c+d x))}{d}+\frac {B \log (\tan (c+d x))}{d}-\frac {4 i A \log (i+\tan (c+d x))}{d}-\frac {4 B \log (i+\tan (c+d x))}{d}-\frac {i B \tan (c+d x)}{d}\right ) \]

[In]

Integrate[Cot[c + d*x]^2*(a + I*a*Tan[c + d*x])^3*(A + B*Tan[c + d*x]),x]

[Out]

a^3*(-((A*Cot[c + d*x])/d) + ((3*I)*A*Log[Tan[c + d*x]])/d + (B*Log[Tan[c + d*x]])/d - ((4*I)*A*Log[I + Tan[c
+ d*x]])/d - (4*B*Log[I + Tan[c + d*x]])/d - (I*B*Tan[c + d*x])/d)

Maple [A] (verified)

Time = 0.24 (sec) , antiderivative size = 84, normalized size of antiderivative = 0.72

method result size
parallelrisch \(\frac {a^{3} \left (4 i B d x +3 i A \ln \left (\tan \left (d x +c \right )\right )-2 i A \ln \left (\sec ^{2}\left (d x +c \right )\right )-4 A d x -i B \tan \left (d x +c \right )-A \cot \left (d x +c \right )+B \ln \left (\tan \left (d x +c \right )\right )-2 B \ln \left (\sec ^{2}\left (d x +c \right )\right )\right )}{d}\) \(84\)
derivativedivides \(\frac {a^{3} \left (-A \cot \left (d x +c \right )+\frac {\left (-4 i A -4 B \right ) \ln \left (\cot ^{2}\left (d x +c \right )+1\right )}{2}+\left (-4 i B +4 A \right ) \left (\frac {\pi }{2}-\operatorname {arccot}\left (\cot \left (d x +c \right )\right )\right )+\left (i A +3 B \right ) \ln \left (\cot \left (d x +c \right )\right )-\frac {i B}{\cot \left (d x +c \right )}\right )}{d}\) \(89\)
default \(\frac {a^{3} \left (-A \cot \left (d x +c \right )+\frac {\left (-4 i A -4 B \right ) \ln \left (\cot ^{2}\left (d x +c \right )+1\right )}{2}+\left (-4 i B +4 A \right ) \left (\frac {\pi }{2}-\operatorname {arccot}\left (\cot \left (d x +c \right )\right )\right )+\left (i A +3 B \right ) \ln \left (\cot \left (d x +c \right )\right )-\frac {i B}{\cot \left (d x +c \right )}\right )}{d}\) \(89\)
norman \(\frac {\left (4 i B \,a^{3}-4 A \,a^{3}\right ) x \tan \left (d x +c \right )-\frac {A \,a^{3}}{d}-\frac {i B \,a^{3} \left (\tan ^{2}\left (d x +c \right )\right )}{d}}{\tan \left (d x +c \right )}+\frac {\left (3 i A \,a^{3}+B \,a^{3}\right ) \ln \left (\tan \left (d x +c \right )\right )}{d}-\frac {2 \left (i A \,a^{3}+B \,a^{3}\right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{d}\) \(114\)
risch \(-\frac {8 i a^{3} B c}{d}+\frac {8 a^{3} A c}{d}+\frac {2 a^{3} \left (-i A \,{\mathrm e}^{2 i \left (d x +c \right )}+B \,{\mathrm e}^{2 i \left (d x +c \right )}-i A -B \right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )}+\frac {3 a^{3} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B}{d}+\frac {i a^{3} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) A}{d}+\frac {a^{3} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right ) B}{d}+\frac {3 i a^{3} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right ) A}{d}\) \(174\)

[In]

int(cot(d*x+c)^2*(a+I*a*tan(d*x+c))^3*(A+B*tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

a^3*(4*I*B*d*x+3*I*A*ln(tan(d*x+c))-2*I*A*ln(sec(d*x+c)^2)-4*A*d*x-I*B*tan(d*x+c)-A*cot(d*x+c)+B*ln(tan(d*x+c)
)-2*B*ln(sec(d*x+c)^2))/d

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 141, normalized size of antiderivative = 1.22 \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx=-\frac {2 \, {\left (i \, A - B\right )} a^{3} e^{\left (2 i \, d x + 2 i \, c\right )} + 2 \, {\left (i \, A + B\right )} a^{3} - {\left ({\left (i \, A + 3 \, B\right )} a^{3} e^{\left (4 i \, d x + 4 i \, c\right )} + {\left (-i \, A - 3 \, B\right )} a^{3}\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - {\left ({\left (3 i \, A + B\right )} a^{3} e^{\left (4 i \, d x + 4 i \, c\right )} + {\left (-3 i \, A - B\right )} a^{3}\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} - 1\right )}{d e^{\left (4 i \, d x + 4 i \, c\right )} - d} \]

[In]

integrate(cot(d*x+c)^2*(a+I*a*tan(d*x+c))^3*(A+B*tan(d*x+c)),x, algorithm="fricas")

[Out]

-(2*(I*A - B)*a^3*e^(2*I*d*x + 2*I*c) + 2*(I*A + B)*a^3 - ((I*A + 3*B)*a^3*e^(4*I*d*x + 4*I*c) + (-I*A - 3*B)*
a^3)*log(e^(2*I*d*x + 2*I*c) + 1) - ((3*I*A + B)*a^3*e^(4*I*d*x + 4*I*c) + (-3*I*A - B)*a^3)*log(e^(2*I*d*x +
2*I*c) - 1))/(d*e^(4*I*d*x + 4*I*c) - d)

Sympy [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 219 vs. \(2 (99) = 198\).

Time = 1.01 (sec) , antiderivative size = 219, normalized size of antiderivative = 1.89 \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx=\frac {i a^{3} \left (A - 3 i B\right ) \log {\left (e^{2 i d x} + \frac {2 A a^{3} - 2 i B a^{3} - a^{3} \left (A - 3 i B\right )}{A a^{3} e^{2 i c} + i B a^{3} e^{2 i c}} \right )}}{d} + \frac {i a^{3} \cdot \left (3 A - i B\right ) \log {\left (e^{2 i d x} + \frac {2 A a^{3} - 2 i B a^{3} - a^{3} \cdot \left (3 A - i B\right )}{A a^{3} e^{2 i c} + i B a^{3} e^{2 i c}} \right )}}{d} + \frac {- 2 i A a^{3} - 2 B a^{3} + \left (- 2 i A a^{3} e^{2 i c} + 2 B a^{3} e^{2 i c}\right ) e^{2 i d x}}{d e^{4 i c} e^{4 i d x} - d} \]

[In]

integrate(cot(d*x+c)**2*(a+I*a*tan(d*x+c))**3*(A+B*tan(d*x+c)),x)

[Out]

I*a**3*(A - 3*I*B)*log(exp(2*I*d*x) + (2*A*a**3 - 2*I*B*a**3 - a**3*(A - 3*I*B))/(A*a**3*exp(2*I*c) + I*B*a**3
*exp(2*I*c)))/d + I*a**3*(3*A - I*B)*log(exp(2*I*d*x) + (2*A*a**3 - 2*I*B*a**3 - a**3*(3*A - I*B))/(A*a**3*exp
(2*I*c) + I*B*a**3*exp(2*I*c)))/d + (-2*I*A*a**3 - 2*B*a**3 + (-2*I*A*a**3*exp(2*I*c) + 2*B*a**3*exp(2*I*c))*e
xp(2*I*d*x))/(d*exp(4*I*c)*exp(4*I*d*x) - d)

Maxima [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 84, normalized size of antiderivative = 0.72 \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx=-\frac {4 \, {\left (d x + c\right )} {\left (A - i \, B\right )} a^{3} + 2 \, {\left (i \, A + B\right )} a^{3} \log \left (\tan \left (d x + c\right )^{2} + 1\right ) - {\left (3 i \, A + B\right )} a^{3} \log \left (\tan \left (d x + c\right )\right ) + i \, B a^{3} \tan \left (d x + c\right ) + \frac {A a^{3}}{\tan \left (d x + c\right )}}{d} \]

[In]

integrate(cot(d*x+c)^2*(a+I*a*tan(d*x+c))^3*(A+B*tan(d*x+c)),x, algorithm="maxima")

[Out]

-(4*(d*x + c)*(A - I*B)*a^3 + 2*(I*A + B)*a^3*log(tan(d*x + c)^2 + 1) - (3*I*A + B)*a^3*log(tan(d*x + c)) + I*
B*a^3*tan(d*x + c) + A*a^3/tan(d*x + c))/d

Giac [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 257 vs. \(2 (104) = 208\).

Time = 1.19 (sec) , antiderivative size = 257, normalized size of antiderivative = 2.22 \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx=\frac {3 \, A a^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 6 \, {\left (i \, A a^{3} + 3 \, B a^{3}\right )} \log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1\right ) - 48 \, {\left (i \, A a^{3} + B a^{3}\right )} \log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + i\right ) + 6 \, {\left (i \, A a^{3} + 3 \, B a^{3}\right )} \log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1\right ) - 6 \, {\left (-3 i \, A a^{3} - B a^{3}\right )} \log \left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right ) + \frac {-10 i \, A a^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 14 \, B a^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 3 \, A a^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 12 i \, B a^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 10 i \, A a^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 14 \, B a^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 3 \, A a^{3}}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}}{6 \, d} \]

[In]

integrate(cot(d*x+c)^2*(a+I*a*tan(d*x+c))^3*(A+B*tan(d*x+c)),x, algorithm="giac")

[Out]

1/6*(3*A*a^3*tan(1/2*d*x + 1/2*c) + 6*(I*A*a^3 + 3*B*a^3)*log(tan(1/2*d*x + 1/2*c) + 1) - 48*(I*A*a^3 + B*a^3)
*log(tan(1/2*d*x + 1/2*c) + I) + 6*(I*A*a^3 + 3*B*a^3)*log(tan(1/2*d*x + 1/2*c) - 1) - 6*(-3*I*A*a^3 - B*a^3)*
log(tan(1/2*d*x + 1/2*c)) + (-10*I*A*a^3*tan(1/2*d*x + 1/2*c)^3 - 14*B*a^3*tan(1/2*d*x + 1/2*c)^3 - 3*A*a^3*ta
n(1/2*d*x + 1/2*c)^2 + 12*I*B*a^3*tan(1/2*d*x + 1/2*c)^2 + 10*I*A*a^3*tan(1/2*d*x + 1/2*c) + 14*B*a^3*tan(1/2*
d*x + 1/2*c) + 3*A*a^3)/(tan(1/2*d*x + 1/2*c)^3 - tan(1/2*d*x + 1/2*c)))/d

Mupad [B] (verification not implemented)

Time = 7.93 (sec) , antiderivative size = 76, normalized size of antiderivative = 0.66 \[ \int \cot ^2(c+d x) (a+i a \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx=\frac {a^3\,\ln \left (\mathrm {tan}\left (c+d\,x\right )\right )\,\left (B+A\,3{}\mathrm {i}\right )}{d}-\frac {4\,a^3\,\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (B+A\,1{}\mathrm {i}\right )}{d}-\frac {A\,a^3\,\mathrm {cot}\left (c+d\,x\right )}{d}-\frac {B\,a^3\,\mathrm {tan}\left (c+d\,x\right )\,1{}\mathrm {i}}{d} \]

[In]

int(cot(c + d*x)^2*(A + B*tan(c + d*x))*(a + a*tan(c + d*x)*1i)^3,x)

[Out]

(a^3*log(tan(c + d*x))*(A*3i + B))/d - (4*a^3*log(tan(c + d*x) + 1i)*(A*1i + B))/d - (A*a^3*cot(c + d*x))/d -
(B*a^3*tan(c + d*x)*1i)/d